package cn.usain.controller;

import cn.jiyun.pojo.Orders;
import cn.jiyun.pojo.vo.OrderResponse;
import cn.usain.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/statistics")
public class StatisticsController {

    @Autowired
    StatisticsService statisticsService;

    @GetMapping("/getOrderResponse")
    public OrderResponse getOrderResponse(){
        return statisticsService.getOrderResponse();
    }


    // 保留之前的查询接口
  /*  @GetMapping("/responseRate")
    public List<Orders> getResponseRate(
            @RequestParam String cityLevel,
            @RequestParam String city,
            @RequestParam String district,
            @RequestParam String orderTime,
            @RequestParam String startTime,
            @RequestParam String endTime,
            @RequestParam String orderType) {
        return statisticsService.getOrdersByCondition(cityLevel, city, district, orderTime, startTime, endTime, orderType);
    }

    // 新增统计响应率的接口
    @GetMapping("/calculateResponseRate")
    public double calculateResponseRate(
            @RequestParam(required = false) String startTime,
            @RequestParam(required = false) String endTime,
            @RequestParam(required = false) String orderType) {
        return statisticsService.calculateResponseRate(startTime, endTime, orderType);
    }*/

    // 获取订单响应率接口
//    @GetMapping("/responseRate")
//    public double getResponseRate() {
//        return statisticsService.calculateResponseRate();
//    }


    // 获取整体订单响应率
   /* @GetMapping("/overallResponseRate")
    public double getOverallResponseRate() {
        return statisticsService.calculateResponseRate();
    }

    // 根据条件获取订单响应率相关数据
    @GetMapping("/responseRate")
    public List<Orders> getResponseRate(
            @RequestParam String cityLevel,
            @RequestParam String city,
            @RequestParam String district,
            @RequestParam String orderTime,
            @RequestParam String startTime,
            @RequestParam String endTime,
            @RequestParam String orderType) {
        return statisticsService.getOrdersByCondition(cityLevel, city, district, orderTime, startTime, endTime, orderType);
    }*/


    @GetMapping("/responseRate")
    public Double getOrderResponseRate() {
        return statisticsService.getOrderResponseRate();
    }
}
